<?php include '../public/header.php' ?>
<?php include '../public/header_index.php' ?>
<body class="laytp-container">
<div id="opt_nav">
</div>

<div class="layui-card" id="search-form">
    <div class="layui-card-body">
        <form class="layui-form" id="TableSearchFormId" lay-filter="TableSearchForm" onkeydown="keyTableSearch('TableSearchForm', 'datalist')">
            <div class="layui-form-item">
                <div class="layui-row">
                    <div class="layui-col-md3">
                        <label class="layui-form-label">流程单号</label>
                        <div class="layui-input-block">
                            <input type="text" name="sericnum" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">销售方联系人</label>
                        <div class="layui-input-block">
                            <input type="text" name="lianer" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">销售方名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="xiaoer" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">工程名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="enginname" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">发票类型</label>
                        <div class="layui-input-block">
                            <div id="qianpiaotype" class="xmselect_div">
                                <div class="xmselect_title">请选择</div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">发票号码</label>
                        <div class="layui-input-block">
                            <input type="text" name="nums" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">开票日期</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="kaidt" placeholder="请输入" autocomplete="off" class="layui-input bdate_sea_range_ymd">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">使用月份</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="usedt" placeholder="请输入" autocomplete="off" class="layui-input bdate_sea_range_ym">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">审核状态：</label>
                        <div class="layui-input-block">
                            <select id="status" name="status" lay-filter="status">
                                <option value="">请选择</option>
                                <option value="1">流程（审批通过）</option>
                                <option value="0">流程（审批中）</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <div class="layui-form-item search-div">
                            <div class="layui-form-item layui-inline">
                                <button class="laytp-btn laytp-btn-md laytp-btn-primary" id="TableSearchButton" type="button"><i class="layui-icon layui-icon-search"></i>查询</button>
                                <button class="layui-btn layui-btn-primary" onclick="listTableReset()" id="TableSearchReset" type="reset" ><i class="layui-icon layui-icon-refresh"></i>重置</button>
                                <div id="search_open" onclick="toggle_search()">
                                    <i class="layui-icon layui-icon-down"></i>展开
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>

<div class="layui-card" id="table-card">
    <div class="layui-card-body">
        <div class="layui-row">
            <div class="layui-col-md12" id="table_list">
                <div class="layui-card-body">
                    <table id="datalist" lay-filter="datalist"></table>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/html" id="test-dropdown-toolbar-barDemo">
    <div class="tab-list-authbut">
        <a href="javascript:;" class="bar_opt" onclick="auth_but_func_show('查看','{{d.LAY_TABLE_INDEX}}')">查看</a>
    </div>
</script>
<script type="text/html" id="toolbarDemo">
    <div class = "layui-btn-container">
        <button class="layui-btn layui-btn-primary outbut" onclick="auth_but_func_use('使用登记')">使用登记</button>
    </div>
</script>
<script>

    var param_status = getQueryVariable('status') || '';
    $("#status").val(param_status)
    var param_xiaoer = decodeURI(getQueryVariable('xiaoer') || '') || '';



    layui.use(["laytp",'laypage','table','dropdown','form','soulTable'], function () {
        var laypage = layui.laypage, table = layui.table, dropdown = layui.dropdown, form = layui.form, soulTable = layui.soulTable;


        $('#TableSearchReset').click(function () {
            $('.xmselect_div>xm-select').find('.xm-label-block').css('display','none');
            $('.xmselect_div').append('<div class="xmselect_title">请选择</div>');
            searchTableFunc(form, table)
        });

        setSouTableExport('储备进项票明细');
        var mytable = table.render({
            elem: "#datalist",id: "datalist"
            ,url: facade.url(ask_piao_chu_detail),where: {status:param_status,xiaoer:param_xiaoer}, page: true, height: 'full-140'
            ,soulSort: TabInit.soulSort,method: TabInit.method, toolbar: TabInit.toolbar, overflow: TabInit.overflow
            ,defaultToolbar: TabInit.defaultToolbar,filter: TabInit.filter
            ,request: TabInit.request,response: TabInit.response,contextmenu:get_table_contextmenu(soulTable)
            ,text: TabInit.text,totalRow: true
            ,parseData: function (res) {
                xmselect_dan('qianpiaotype', res.data.qianpiaotype, res.data.is_qianpiaotype, function (res) {
                    setTimeout(function () {
                        searchTableFunc(form, table);
                    },100)
                })

                render_from();
                return {
                    "code": res.code,
                    "msg": res.message,
                    "count": res.data.data.total,
                    "data": res.data.data.data
                };
            }
            , cols: [[
                {type: "checkbox", fixed: 'left'}
                ,{type:'numbers',title:'序号',totalRowText: '合计',fixed:'left'}
                ,{field:'sericnum',title:'流程单号',templet: function(d){
                        return '<span class="colorlan" onclick="openPage(\'../piao_chu/show.php?id='+d.id+'\');">'+d.sericnum+'</span>';
                    }}
                ,list_bill_cols_str
                ,{field: 'nums', title: '发票号码'}
                ,{field: 'usedt', title: '使用月份'}
                ,{field: 'xiaoer', title: '销售方名称'}
                ,{field: 'qianpiaotype_name', title: '发票类型'}
                ,{field: 'kaidt', title: '开票日期'}
                ,{field: 'cailei', title: '材料种类'}
                ,{field:'fee',title:'不含税金额(元)',totalRow: true,templet: function(d){
                        return parseFormatNum(d.fee);
                    }}
                ,{field: 'rate', title: '税率(%)'}
                ,{field:'listratefee',title:'税额(元)',totalRow: true,templet: function(d){
                        return parseFormatNum(d.listratefee);
                    }}
                ,{field:'listmoney',title:'价税合计(元)',totalRow: true,templet: function(d){
                        return parseFormatNum(d.listmoney);
                    }}
                ,{field: 'huidt', title: '回票日期'}
                ,{field:'difee',title:'本次关联付款金额(元)',totalRow: true,templet: function(d){
                        return parseFormatNum(d.difee);
                    }}
                ,{field:'statename',title:'付款状态',templet: function(d){
                    if(d.statename == '已付款'){
                        return '<span class="colorlv">'+d.statename+'</span>';
                    }else if(d.statename == '部分付款'){
                        return '<span class="colorhuang">'+d.statename+'</span>';
                    }else if(d.statename == '未付款'){
                        return '<span class="colorhong">'+d.statename+'</span>';
                    }else{
                        return d.statename;
                    }
                }}
                ,{field:'yifufee',title:'累计已付款金额(元)',totalRow: true,templet: function(d){
                        return parseFormatNum(d.yifufee);
                    }}
                ,{field:'daifufee',title:'待付款金额(元)',totalRow: true,templet: function(d){
                        return parseFormatNum(d.daifufee);
                    }}
                ,{field:'conname',title:'储备合同名称',templet: function(d){
                    if(d.chuid > 0){
                        return '<span class="colorlan" onclick="openPage(\'../contract_chu/show.php?id='+d.chuid+'\');">'+d.conname+'</span>';
                    }else{
                        return ''
                    }
                }}
                ,{field: 'connumber', title: '合同编号'}
            ]]
            , done: function (res) {
                soulTable.render(this);
            }
        });


        listTableSearch(form, table);
    });

    function auth_but_func_use(buttitle){
        var idArr = get_table_check_listidarr();
        if(idArr.length < 1){
            facade.error(buttitle + "：请选择数据");return false;
        }
        openPageEdit('use.php?close=1&ids='+idArr.join(','), '770px', '490px');
    }



    function get_table_check_listidarr(datalist='datalist') {
        var checkStatus = layui.table.checkStatus(datalist).data;
        var ids = [];
        for(var i=0;i<checkStatus.length;i++){
            ids.push(checkStatus[i].listid)
        }
        return ids;
    }
</script>
</body>
</html>
